import { Injectable } from '@angular/core';

@Injectable({
  providedIn: 'root',
})
export class StorageService {
  public set(key: string, value: any): boolean {
    try {
      window.localStorage.setItem(key, value);
      return true;
    } catch (reason) {
      return false;
    }
  }

  public get(key: string): string {
    try {
      const result = window.localStorage.getItem(key);
      return result;
    } catch (reason) {
      return null;
    }
  }

  public remove(key: string): boolean {
    try {
      window.localStorage.remove(key);
      return true;
    } catch (reason) {
      return false;
    }
  }
}
